<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目编号">
              <a-input placeholder="请输入项目编号" v-model="queryParam.xmbh"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.xmmc"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="10" :sm="24">
            <a-form-item label="发布时间">
              <j-date :show-time="true" date-format="YYYY-MM-DD" placeholder="请选择开始时间" class="query-group-cust" v-model="queryParam.fbsj_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date :show-time="true" date-format="YYYY-MM-DD" placeholder="请选择结束时间" class="query-group-cust" v-model="queryParam.fbsj_end"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="结算单号">
              <a-input placeholder="请输入结算单号" v-model="queryParam.jsdh"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="3" :lg="7" :md="5" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-popconfirm title="确定重新支付该服务费金额吗?" @confirm="() => handleChange(record.id, 2)" v-if="record.payresult == '失败' && record.balance != '0' && record.balance != '0.00' ">
            <a>重新支付</a>
          </a-popconfirm>
          <a v-if="record.payresult == '成功'" @click="viewHd(record)">查看回单</a>
        </span>

      </a-table>
    </div>

    <a-modal
      title="查看回单"
      :visible="visibleHd"
      width="1000px"
      cancelText="关闭"
      @cancel="HdClose"
      :okButtonProps="{ class:{'jee-hidden': true} }"
    >
      <div  id="hd" style="width:960px;height:600px;">
        <iframe style="width: 100%;height: 100%;" :src="hdImgUrl"></iframe>
      </div>
    </a-modal>

  </a-card>
</template>

<script>

    import '@/assets/less/TableExpand.less'
    import { mixinDevice } from '@/utils/mixin'
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
    import JInput from '@/components/jeecg/JInput'
    import JDate from '@/components/jeecg/JDate.vue'

    export default {
        name: 'fwfjszx',
        mixins:[JeecgListMixin, mixinDevice],
        components: {
            JDictSelectTag,
            JInput,
            JDate
        },
        data () {
            return {
                description: '服务费账单明细管理页面',
                // 表头
                columns: [
                    {
                        title:'结算单号',
                        align:"center",
                        dataIndex: 'jsdh'
                    },
                    {
                        title:'项目编号',
                        align:"center",
                        dataIndex: 'xmbh'
                    },
                    {
                        title:'项目协议编号',
                        align:"center",
                        dataIndex: 'xmxybh'
                    },
                    {
                        title:'项目名称',
                        align:"center",
                        dataIndex: 'xmmc'
                    },
                    {
                        title:'发布时间',
                        align:"center",
                        dataIndex: 'fbsj',
                        customRender:function (text) {
                            return !text?"":(text.length>10?text.substr(0,10):text)
                        }
                    },
                    {
                        title:'服务费金额',
                        align:"center",
                        dataIndex: 'balance'
                    },
                    {
                        title:'银行业务参考号',
                        align:"center",
                        dataIndex: 'serialCode',
                    },
                    {
                        title:'支付状态',
                        align:"center",
                        dataIndex: 'payresult',
                    },
                    {
                        title:'支付时间',
                        align:"center",
                        dataIndex: 'createTime',
                       customRender:function (text) {
                           return !text?"":(text.length>10?text.substr(0,10):text)
                       }
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align:"center",
                        width:120,
                        scopedSlots: { customRender: 'action' }
                    }
                ],
                url: {
                    list: "/project/lhygWxMoneyDetail/fwflist",
                    exportXlsUrl: "/project/lhygWxMoneyDetail/exportXls",
                    importExcelUrl: "project/lhygWxMoneyDetail/importExcel",
                    updateStatus: "/project/lhygWxMoneyDetail/updateStatus"
                },
                dictOptions:{},
                visibleHd: false,
                hdImgUrl: '',
            }
        },
        created() {
        },
        computed: {
            importExcelUrl: function(){
                return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
            },
        },
        methods: {
            initDictConfig(){
            },
            viewHd(record){
                if(record.hdurl == undefined || record.hdurl == null || record.hdurl == ""){
                    this.$message.warning("回单等待中");
                    this.visibleHd = false;
                } else {
                    this.hdImgUrl = record.hdurl;
                    this.visibleHd = true;
                }
            },
            HdClose(){
                this.visibleHd = false;
            },
        }
    }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>